﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using OpenTK;

namespace LasRendering
{
    public static class VectorHelper
    {
        public static float GetValueByAxis(Vector3 v, int axis)
        {
            switch (axis)
            {
                case 0:
                    return v.X;
                case 1:
                    return v.Y;
                case 2:
                    return v.Z;
                default:
                    throw new InvalidOperationException();
            }
        }

        public static Vector3 Parse(string s)
        {
            if (string.IsNullOrEmpty(s))
            {
                return new Vector3();
            }

            string[] valueArray = s.Split(new char[] { ' ', ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
            Debug.Assert(valueArray.Length == 3);
            return new Vector3(
                Convert.ToSingle(valueArray[0]),
                Convert.ToSingle(valueArray[1]),
                Convert.ToSingle(valueArray[2]));
        }

    }
}
